package Demo;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;

public class CardDemo {
    public static final String[] SUITS={"♥","♦","♠","♦"};

    //买一副牌
    public  List<Card> buyDeck(){

        List<Card> cards=new ArrayList<>();
        for (int i=0;i<4;i++){

            for (int j=1;j<=13;j++){

                cards.add(new Card(SUITS[i],j));
            }
        }
        return cards;
    }
//洗牌

    public  void shuffle(List<Card> cards){

        Random random=new Random();

        for (int i = cards.size()-1; i>0; i--) {

            int index=random.nextInt(i);

            swap(cards,i,index);//交换

        }

    }
    public void swap(List<Card> cards,int i,int index){
        Card  tmp=cards.get(i);
        cards.set(i,cards.get(index));
        cards.set(index,tmp);

    }
    /*
    *
    * 揭牌*/
    public List<List<Card>> SetCard(List<Card> listCard){
        List<Card> head1=new ArrayList<>();
        List<Card> head2=new ArrayList<>();
        List<Card> head3=new ArrayList<>();

        List<List<Card>> hand=new ArrayList<>();

        hand.add(head1);
        hand.add(head2);
        hand.add(head3);


        for (int i=0;i<5;i++){

            for (int j = 0; j < 3; j++) {

                Card card=listCard.remove(0);

                hand.get(j).add(card);
            }
        }


        return hand;

    }
    public static void main1(String[] args) {
//        System.out.println(CardDemo.buyDeck());
/*
          Iterator<Card> IC=CardDemo.buyDeck().iterator();
          while (IC.hasNext()){

              System.out.print(IC.next()+" ");
          }

        }*/
    }
    }
